package dominion.player;

import dominion.Dominion;
import dominion.kingdom.Adventurer;
import dominion.kingdom.MitchellsChapel;

public class AdventurerPlayer extends TresureOnlyPlayer {

	MitchellsChapel chapel;
	Adventurer adventurer;

	public AdventurerPlayer(Dominion dominion) {
		this("Adventurer", dominion);
	}

	public AdventurerPlayer(String name, Dominion dominion) {
		super(name, dominion);
	}

	@Override
	public int buy(Dominion dominion, int value) {
		if (this.chapel == null && 1 < value) {
			this.chapel = new MitchellsChapel();
			if (dominion.buy(this, this.chapel)) {
				value -= 2;
			}
		} else if (this.adventurer == null && 6 == value) {
			this.adventurer = new Adventurer();
			if (dominion.buy(this, this.adventurer)) {
				value -= 6;
			}
		} else {
			value = super.buy(dominion, value);
		}
		return value;
	}

}
